package com.lnsf.bookstore.web.advertise.controller;

import com.lnsf.bookstore.common.annotation.IgnoreAuth;
import com.lnsf.bookstore.common.controller.ApiBaseAction;
import com.lnsf.bookstore.common.dao.BaseDao;
import com.lnsf.bookstore.web.advertise.service.ApiAdvertiseService;
import com.lnsf.bookstore.web.advertise.vo.ApiAdvertise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
    @RequestMapping("/api/adverise")
public class ApiAdvertiseController extends ApiBaseAction{

    @Autowired
    private ApiAdvertiseService apiAdvertiseService;

    /**
     * 某位置的广告
     * @param adv_position_id
     * @return
     */
    @RequestMapping("/getAdByPosition/{id}")
    @ResponseBody
    @IgnoreAuth
    public Object getAd(@PathVariable("id") Integer adv_position_id){
        //存数据的
        Map<String, Object> resultObj = new HashMap();
        Map param = new HashMap();
        param.put("adv_position_id", adv_position_id);
        List<ApiAdvertise> banner = apiAdvertiseService.queryList(param);
        resultObj.put("banner",banner);
        return toResponsSuccess(resultObj);
    }
}
